<template>
  <div class="home">
    <headNav />
    <headSonNav />
    <leftNav />
    <div v-if="$store.state.activityId.thisActivityId" class="main-box">
      <router-view />
    </div>
  </div>
</template>

<script>
import headNav from "@/components/head";
import headSonNav from "@/components/headSonNav";
import leftNav from "@/components/leftNav";
export default {
  name: "home",
  components: {
    headNav,
    headSonNav,
    leftNav
  }, // 监听,当路由发生变化的时候执行
  watch: {
    $route: {
      handler: function(val, oldVal) {
        // 确定导航栏
        this.$store.state.router.thisNav = val.meta.navList;
        this.$store.state.router.thisRouterName = val.name;

        // 判断哪些页面是否可以切换活动
        let routerList = ["/allTicket/ticketDeile"]; //不可以切换活动的路由数组
        let value = routerList.indexOf(val.path);
        if (value == -1) {
          this.$store.state.router.disabledSelectActivity = false;
        } else {
          this.$store.state.router.disabledSelectActivity = true;
        }

        // 清空字段value值
        let fieldList = this.$store.state.activityId.fieldList;
        for (let i = 0; i < fieldList.length; i++) {
          fieldList[i].attribute.filedValue = "";
        }
      },
      // 深度观察监听
      deep: true
    }
  }
};
</script>

<style scoped>
.home {
  padding: 86px 20px 86px 146px;
  width: 100%;
  height: auto;
}
.main-box {
  width: 100%;
  height: auto;
}
</style>
